package march.test_3_17;

import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int[] hash = new int[1000];
        for (int i = 0; i < str.length(); i++) {
            hash[str.charAt(i)]++;
        }
        int n = scanner.nextInt();
        String a = scanner.nextLine();
        for (int i = 0; i < n; i++) {
            String tmp = scanner.nextLine();
            if(hash[tmp.charAt(0)] != 0 || hash[tmp.charAt(tmp.length() -1)] != 0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
    public static boolean isLike(String s,String t) {
        for (int i = 1; i <= t.length(); i++) {
            String tmp = t.substring(0,i);

            if(s.contains(tmp)) {
                return true;
            }
            String count = t.substring(t.length()-i,t.length());
            if(s.contains(count)) {
                return true;
            }
        }
        return false;
    }
    public static boolean isSon(String p,String s) {
        for (int i = 0; i < p.length(); i++) {
            boolean tmp = true;
            if(p.charAt(i) == s.charAt(0)) {
                for (int j = i; j - i < s.length(); j++) {
                    if(j >= p.length() || p.charAt(i) != s.charAt(j - i)) {
                        tmp = false;
                        break;
                    }
                }
                if(tmp) {
                    return true;
                }
            }
        }
        return false;
    }
}
